package com.bnq.control.common.utils;

import java.io.Closeable;
import java.io.IOException;

/**
 * Created by shikh on 2018/3/7.
 */

public class CloseUtils {

    /**
     * 关闭closeble对象
     * @param closeable
     */
    public static void closeQuietly(Closeable closeable) {
        if(null != closeable){
            try {
                closeable.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 传入多个closeble对象关闭
     * @param closeables
     */
    public static void closeQuietly(Closeable... closeables){
        if(null != closeables){
            for (Closeable closeable : closeables) {
                try {
                    if(null != closeable){
                        closeable.close();
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
